package cn.bdqn.controller;

import cn.bdqn.dto.Dto;
import cn.bdqn.pojo.ItripLabelDic;
import cn.bdqn.service.CommentService;
import cn.bdqn.vo.ItripLabelDicVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(description = "出游")
@Controller
public class Comment {


    @Resource
    private CommentService commentService;

    @ResponseBody
    @ApiOperation(value = "出游信息",httpMethod = "get",protocols = "HTTP",produces = "application/json",response = Dto.class)
    @RequestMapping(value = "/api/comment/gettraveltype",method = RequestMethod.GET,produces = "application/json")
    public Dto getTravelType(){
        Dto dto=new Dto();
        Long parentId=107L;
        Map map=new HashMap();
        map.put("parentId",parentId);
        List<ItripLabelDicVO> itripLabelDicVOS=new ArrayList<ItripLabelDicVO>(0);
        List<ItripLabelDic> labelDics1s=commentService.selectByPId(map);
        if (labelDics1s.size()>0&&!labelDics1s.isEmpty()){
            for (ItripLabelDic itripLabelDic:labelDics1s){
                ItripLabelDicVO itripLabelDicVO=new ItripLabelDicVO();
                itripLabelDicVO.setId(itripLabelDic.getId());
                itripLabelDicVO.setName(itripLabelDic.getName());
                itripLabelDicVO.setPic(itripLabelDic.getPic());
                itripLabelDicVO.setDescription(itripLabelDic.getDescription());
                itripLabelDicVOS.add(itripLabelDicVO);
            }
            dto.setData("0");
            dto.setMsg("读取信息成功");
            dto.setSuccess("true");
            dto.setData(itripLabelDicVOS);
            return dto;
        }else {
            dto.setData("10086");
            dto.setMsg("读取信息失败");
            dto.setSuccess("false");
            return dto;
        }

    }

}
